<!-- 安装件管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label" v-if="!pup">安装件管理</p>

    <div :class="!pup ? 'btm mt10 pt10' : ''">
      <dxtable
        :dataJson="dataJson"
        :portUrl="portUrl"
        :qx="qx"
        ref="databale"
        :formJson="formJson"
        imgkuTitle="视频上传"
        accept=".mp4"
        :headBtn="headBtn"
        :checkedRowKeys="checkedRowKeys"
          bjtext = "修改"
      ></dxtable>
    </div>
  </div>
</template>
 <script lang='ts' setup>
import dxtable from "../../../components/util/dxtable.vue";
import sort from "../../../components/util/sort.vue";
import { NSwitch } from "naive-ui";
import { dxget, dxpost, qurl, hf } from "../../../util/index";
import { h, ref, reactive } from "vue";
import { NButton } from "naive-ui";
const cz = qurl();
const databale = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
const props = defineProps({
  pup: { type: String },
  checkedRowKeys: {
    type: Array,
    default: null,
  },
});
const emit = defineEmits(["callBack"]);
// 弹窗公用该列表
let dataJson = reactive([
  {
    title: "安装件名称",
    key: "name",
    placeholder:"输入关键字查询",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "机型",
    key: "type",
    type: "select",
    options: [],
  },

  {
    title: "排序",
    width: 100,
    render(row) {
      row.databaseName = "kxInstallationComponentManagement";
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "创建时间",
    key: "addTime",
    width: "200",
    type: "daterange",
  },
]);
let portUrl = "kx/kxInstallationComponentManagement";
const qx = {
  DeletePermissionID: "kxInstallationComponentdel", //删除
  EditPermissionIdentifier: "kxInstallationComponentbj", // 编辑
  NewPermissionIdentifier: "kxInstallationComponentxz", // 新建
  ViewPermissionID: "kxInstallationComponentck", // 查看
};

let formJson = reactive([
  {
    title: "安装件名称",
    key: "name",
    type: "input",
    required: true,
  },
  {
    title: "机型",
    key: "type",
    type: "select",
    options: [],
    required: true,
  },
  {
    title: "视频上传",
    key: "video",
    type: "video",
    required: true,
  },
  {
    title: "安装件说明",
    key: "explain",
    type: "textarea",
    required: true,
  },
]);
let headBtn = [];
let pupVal = cz.pup || props.pup;
if (pupVal) {
  headBtn = [
    {
      name: "确认选择 ",
      async clickFun(row) {
        const arrList = row.join(",");
        emit("callBack", arrList);
      },
    },
  ];
}

const setXl = (text, data) => {
  const kjhaea = [];
  data.split(",").map((a) => {
    let obj = {
      label: a,
      value: a,
    };
    kjhaea.push(obj);
  });
  formJson.filter((a) => a.key == text)[0].options = kjhaea;
  dataJson.filter((a) => a.key == text)[0].options = kjhaea;
};

const initSelect = async () => {
  const { data }: any = await dxget("beRelieved/dictionaries?type=2", {
    id: 26,
  });
  if (data.dlabel) {
    setXl("type", data.dlabel);
  }
};
initSelect();
</script>
 <style scoped>
</style>


